home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr26 / blrmu13.zip / PM.ASM < prev    next >
Assembly Source File  |  1993-06-01  |  11KB  |  360 lines

  1. page ,132
  2. title pm ( put message ) as of 12/17/90 - 01:00 pm
  3. ;*-------------------------------------------------
  4. ;
  5. ;        Put Message
  6. ;
  7. ;        sets the cursor to a specified row and column,
  8. ;        and displays the specified message.
  9. ;        ( for batch file use )
  10. ;
  11. ;        syntax : pm r=rr,c=cc,m=amamamamamamamamamamamamamamamamamam
  12. ;
  13. ;        where rr = row ( 01-25 decimal )
  14. ;        where cc = column ( 01-80 decimal )
  15. ;        where am = ascii message
  16. ;
  17. ;        if no parms,
  18. ;        default to current row and col,
  19. ;        msg = '........................................'
  20. ;
  21. ;        if error im parms,
  22. ;        default to current row and col,
  23. ;        msg = '******   Parameter Syntax Error   ******'
  24. ;
  25. ;*-------------------------------------------------
  26. ;
  27. ;*--------------------------------
  28. mswl     macro dest,sors,length
  29. ;*--------------------------------
  30. ;   move short with length
  31. ;
  32. ;   will move the 'sors' to the
  33. ;   'dest' for 'length' value
  34. ;   ( max length = 255 )
  35. ;*--------------------------------
  36.          push  cx                      ; save
  37.          push  di                      ; used
  38.          push  si                      ; regs
  39. ;
  40.          mov   ch,0                    ; clear hi
  41.          mov   cl,length               ; load lo
  42.          lea   di,dest                 ; dest index
  43.          lea   si,sors                 ; sors index
  44.          cld                           ; set direction forward
  45.          rep   movsb                   ; repeat move string by byte
  46. ;
  47.          pop   si                      ; restore
  48.          pop   di                      ; used
  49.          pop   cx                      ; regs
  50.          endm
  51. ;
  52. ;*------------------------------------
  53. pc       macro fld,len,char
  54. ;*------------------------------------
  55. ;* propagate character
  56. ;*------------------------------------
  57. ;* the area named 'fld',
  58. ;* for a length of 'len'
  59. ;* will be filled with 'char'
  60. ;*------------------------------------
  61.          push  ax
  62.          push  cx
  63.          push  di
  64.          lea   di,fld
  65.          mov   cx,len
  66.          mov   al,char
  67.          cld
  68.          rep   stosb
  69.          pop   di
  70.          pop   cx
  71.          pop   ax
  72.          endm
  73. ;
  74. ;*-------------------------------------------------
  75. code     segment para public 'code'
  76. ;
  77.          assume  cs:code,ds:code,es:code
  78. ;
  79.          org   128
  80. ;
  81. pl       db    0            ; parm len ( includes space )
  82.          db    0            ; space
  83. rk       db    0            ; row key
  84.          db    0            ; =
  85. r        db    0,0          ; rr         ( yy )
  86.          db    0            ; ,
  87. ck       db    0            ; column key
  88.          db    0            ; =
  89. c        db    0,0          ; cc         ( xx )
  90.          db    0            ; ,
  91. mk       db    0            ; m
  92.          db    0            ; =
  93. m        db    40 dup(0)    ; '1234567890123456789012345678901234567890'
  94. ;
  95.          org   256
  96. ;
  97. ;*---------------------
  98. ;*   put message
  99. ;*---------------------
  100. pm:
  101.          jmp   doit
  102. ;
  103. ;*--------------------------------------------------------------
  104. cr       db    0                       ; current row
  105. cc       db    0                       ; current column
  106. sr       db    0                       ; save row
  107. sc       db    0                       ; save column
  108. um       db    40 dup(0)               ; user msg
  109.          db    0,0,0                   ; dmy
  110. errm     db    '******   Parameter Syntax Error   ******'
  111.          db    0,0,0
  112. mtf      dw    1                       ; multiply temp fld
  113. ;*--------------------------------------------------------------
  114. ;
  115. doit:
  116. ;
  117.          pc    um,40,0                 ; initialize user msg
  118. ;
  119. ;*-----------------------
  120. ;*  get cursor position
  121. ;*-----------------------
  122. ;
  123.          mov   ah,3
  124.          mov   bh,0
  125.          int   16
  126. ;
  127.          mov   cr,dh                   ; get current row
  128.          mov   cc,dl                   ; get current col
  129. ;
  130.          cmp   pl,0                    ; parm len = 0 ?
  131.          je    nomsg                   ; if so, no msg
  132. ;
  133. crk:                                   ; check row key
  134. ;
  135.          mov   al,rk                   ; get row key
  136. ;
  137.          cmp   al,'r'                  ; row key there ?
  138.          je    ckc                     ; if so, check col key
  139.          cmp   al,'R'                  ; row key there ?
  140.          je    ckc                     ; if so, check col key
  141.          cmp   al,32                   ; space ?
  142.          je    nomsg                   ; if so, no msg
  143.          jmp   errmsg                  ; else, error msg
  144. ;
  145. ckc:                                   ; check column key
  146. ;
  147.          mov   al,ck                   ; get column key
  148. ;
  149.          cmp   al,'c'                  ; col key there ?
  150.          je    cmk                     ; if so, check msg key
  151.          cmp   al,'C'                  ; background key there ?
  152.          je    cmk                     ; if so, check msg key
  153.          jmp   errmsg                  ; else, error msg
  154. ;
  155. cmk:                                   ; check msg key
  156. ;
  157.          mov   al,mk                   ; get msg key
  158. ;
  159.          cmp   al,'m'                  ; msg key there ?
  160.          je    mtm                     ; if so, move the msg
  161.          cmp   al,'M'                  ; msg key there ?
  162.          je    mtm                     ; if so, move the msg
  163.          jmp   errmsg                  ; else, error msg
  164. ;
  165. mtm:                                   ; move the msg
  166. ;
  167.          lea   si,m                    ; sors ptr
  168.          lea   di,um                   ; dest ptr
  169.          mov   cx,40                   ; max cnt
  170. ;
  171. mtml:
  172. ;
  173.          mov   al,[si]                 ; get a byte
  174.          cmp   al,0                    ; zero ?
  175.          je    mtmx                    ; if so, exit
  176.          cmp   al,13                   ; CR ?
  177.          je    mtmx                    ; if so, exit
  178.          mov   byte ptr[di],al         ; move srs to dest
  179.          inc   si                      ; incr srs ptr
  180.          inc   di                      ; incr dest ptr
  181.          loop  mtml                    ; loop
  182. ;
  183. mtmx:                                  ; move the msg exit
  184. ;
  185.          jmp   pp                      ; process params
  186. ;
  187. ;*---------------------
  188. ;*  no message
  189. ;*---------------------
  190. ;
  191. nomsg:
  192. ;
  193.          mov   al,cr                   ; current
  194.          mov   sr,al                   ; row
  195.          mov   al,cc                   ; current
  196.          mov   sc,al                   ; col
  197.          pc    um,40,'.'               ; move 40 periods to msg
  198.          jmp   scp                     ; and skip process parameters
  199. ;
  200. ;*---------------------
  201. ;*  error message
  202. ;*---------------------
  203. ;
  204. errmsg:
  205. ;
  206.          mov   al,cr                   ; current
  207.          mov   sr,al                   ; row
  208.          mov   al,cc                   ; current
  209.          mov   sc,al                   ; col
  210.          mswl  um,errm,40              ; move error msg to msg
  211.          jmp   scp                     ; and skip process parameters
  212. ;
  213. ;*----------------------
  214. ;*  process parameters
  215. ;*----------------------
  216. ;
  217. pp:
  218. ;
  219.          lea   si,r                    ; ptr to in
  220.          lea   di,sr                   ; ptr to out
  221.          mov   sr,0                    ; clear out
  222.          mov   bx,2                    ; set in len
  223.          call  catb                    ; convert
  224. ;
  225.          lea   si,c                    ; ptr to in
  226.          lea   di,sc                   ; ptr to out
  227.          mov   sc,0                    ; clear out
  228.          mov   bx,2                    ; set in len
  229.          call  catb                    ; convert
  230. ;
  231. ;  check and adjust row
  232. ;
  233.          cmp   sr,25                   ; max ?
  234.          ja    srt1                    ; if GT, set to 1
  235.          cmp   sr,1                    ; min ?
  236.          jb    srt1                    ; if LT, set to 1
  237.          jmp   asr                     ; adjust
  238. ;
  239. srt1:
  240.          mov   sr,1                    ; set row to 1
  241. ;
  242. asr:                                   ; adjust saved row
  243. ;
  244.          mov   al,sr
  245.          dec   al
  246.          mov   sr,al
  247. ;
  248. ;  check and adjust col
  249. ;
  250.          cmp   sc,80                   ; max ?
  251.          ja    sct1                    ; if GT, set to 1
  252.          cmp   sc,1                    ; min ?
  253.          jb    sct1                    ; if LT, set to 1
  254.          jmp   asc
  255. ;
  256. sct1:
  257.          mov   sc,1                    ; set col to 1
  258. ;
  259. asc:                                   ; adjust saved col
  260. ;
  261.          mov   al,sc
  262.          dec   al
  263.          mov   sc,al
  264. ;
  265. ;*------------------------
  266. ;*  set cursor position
  267. ;*------------------------
  268. ;
  269. scp:
  270.          mov   ah,2                    ; set cursor position fct
  271.          mov   bh,0                    ; page 0
  272.          mov   dh,sr                   ; get saved row
  273.          mov   dl,sc                   ; get saved col
  274.          int   16
  275. ;
  276. ;*--------------------------------
  277. ;*  put user msg to the screen
  278. ;*--------------------------------
  279. ;
  280.          lea   ax,um                   ; user msg ptr
  281.          call  lmts                    ; list msg to scrn
  282. ;
  283. ;*--------------------
  284. ;*  return to DOS
  285. ;*--------------------
  286. ;
  287. exit:
  288.          mov   al,0                    ; ret code = 0
  289.          mov   ah,76                   ; term with ret code
  290.          int   33
  291. ;
  292. ;*------------------------------
  293. ;*   convert ascii to binary
  294. ;*------------------------------
  295. ;*------------------------------
  296. ;* converts an ascii decimal
  297. ;* input pointed to by si,
  298. ;* to a dw binary output field
  299. ;* pointed to by di,
  300. ;* with the input width in bx,
  301. ;* and using a dw multiply
  302. ;* temporary field named mtf
  303. ;*------------------------------
  304. catb     proc  near
  305.          push  ax
  306.          push  cx
  307.          mov   cx,10
  308.          mov   mtf,1
  309.          sub   si,1
  310. ;
  311. catbl:
  312.          mov   al,[si+bx]
  313.          and   ax,15
  314.          mul   mtf
  315.          add   [di],ax
  316.          mov   ax,mtf
  317.          mul   cx
  318.          mov   mtf,ax
  319.          dec   bx
  320.          jnz   catbl
  321.          pop   cx
  322.          pop   ax
  323.          ret
  324. catb     endp
  325. ;
  326. ;*------------------------------
  327. ;*     lmts.prc
  328. ;*------------------------------
  329. ;*   list msg to screen
  330. ;*------------------------------
  331. lmts     proc  near
  332.          push  ax
  333.          push  bx
  334.          push  cx
  335.          push  si
  336.          mov   bx,ax
  337.          mov   cx,512
  338.          mov   si,0
  339. lmtsl:
  340.          mov   al,[bx][si]
  341.          cmp   al,0
  342.          je    lmtsx
  343.          int   41
  344.          inc   si
  345.          loop  lmtsl
  346. lmtsx:
  347.          pop   si
  348.          pop   cx
  349.          pop   bx
  350.          pop   ax
  351.          ret
  352. lmts     endp
  353. ;
  354. ;*----------------------------
  355. ;
  356. code     ends
  357. ;
  358.          end   pm
  359. ;
  360.